// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.


suite("test_cast_to_largeint_from_datetimev2_0_part0") {

    // This test case is generated from the correspoinding be UT test case,
    // update this case if the correspoinding be UT test case is updated,
    // e.g.: ../run-be-ut.sh --run --filter=FunctionCastToDecimalTest.* --gen_regression_case
    sql "drop table if exists test_cast_to_largeint_from_datetimev2_0_part0_0_nullable;"
    sql "create table test_cast_to_largeint_from_datetimev2_0_part0_0_nullable(f1 int, f2 datetimev2(0)) properties('replication_num'='1');"
    sql """insert into test_cast_to_largeint_from_datetimev2_0_part0_0_nullable values (0, "0000-01-01 00:00:00"),(1, "0000-01-01 00:00:00"),(2, "0000-01-01 00:00:00"),(3, "0000-01-01 00:00:01"),(4, "0000-01-01 00:00:01"),(5, "0000-01-01 00:00:01"),(6, "0000-01-01 00:00:59"),(7, "0000-01-01 00:00:59"),(8, "0000-01-01 00:00:59"),(9, "0000-01-01 00:01:00"),(10, "0000-01-01 00:01:00"),(11, "0000-01-01 00:01:00"),(12, "0000-01-01 00:01:01"),(13, "0000-01-01 00:01:01"),(14, "0000-01-01 00:01:01"),(15, "0000-01-01 00:01:59"),(16, "0000-01-01 00:01:59"),(17, "0000-01-01 00:01:59"),(18, "0000-01-01 00:59:00"),(19, "0000-01-01 00:59:00"),
      (20, "0000-01-01 00:59:00"),(21, "0000-01-01 00:59:01"),(22, "0000-01-01 00:59:01"),(23, "0000-01-01 00:59:01"),(24, "0000-01-01 00:59:59"),(25, "0000-01-01 00:59:59"),(26, "0000-01-01 00:59:59"),(27, "0000-01-01 01:00:00"),(28, "0000-01-01 01:00:00"),(29, "0000-01-01 01:00:00"),(30, "0000-01-01 01:00:01"),(31, "0000-01-01 01:00:01"),(32, "0000-01-01 01:00:01"),(33, "0000-01-01 01:00:59"),(34, "0000-01-01 01:00:59"),(35, "0000-01-01 01:00:59"),(36, "0000-01-01 01:01:00"),(37, "0000-01-01 01:01:00"),(38, "0000-01-01 01:01:00"),(39, "0000-01-01 01:01:01"),
      (40, "0000-01-01 01:01:01"),(41, "0000-01-01 01:01:01"),(42, "0000-01-01 01:01:59"),(43, "0000-01-01 01:01:59"),(44, "0000-01-01 01:01:59"),(45, "0000-01-01 01:59:00"),(46, "0000-01-01 01:59:00"),(47, "0000-01-01 01:59:00"),(48, "0000-01-01 01:59:01"),(49, "0000-01-01 01:59:01"),(50, "0000-01-01 01:59:01"),(51, "0000-01-01 01:59:59"),(52, "0000-01-01 01:59:59"),(53, "0000-01-01 01:59:59"),(54, "0000-01-01 23:00:00"),(55, "0000-01-01 23:00:00"),(56, "0000-01-01 23:00:00"),(57, "0000-01-01 23:00:01"),(58, "0000-01-01 23:00:01"),(59, "0000-01-01 23:00:01"),
      (60, "0000-01-01 23:00:59"),(61, "0000-01-01 23:00:59"),(62, "0000-01-01 23:00:59"),(63, "0000-01-01 23:01:00"),(64, "0000-01-01 23:01:00"),(65, "0000-01-01 23:01:00"),(66, "0000-01-01 23:01:01"),(67, "0000-01-01 23:01:01"),(68, "0000-01-01 23:01:01"),(69, "0000-01-01 23:01:59"),(70, "0000-01-01 23:01:59"),(71, "0000-01-01 23:01:59"),(72, "0000-01-01 23:59:00"),(73, "0000-01-01 23:59:00"),(74, "0000-01-01 23:59:00"),(75, "0000-01-01 23:59:01"),(76, "0000-01-01 23:59:01"),(77, "0000-01-01 23:59:01"),(78, "0000-01-01 23:59:59"),(79, "0000-01-01 23:59:59"),
      (80, "0000-01-01 23:59:59"),(81, "0000-01-28 00:00:00"),(82, "0000-01-28 00:00:00"),(83, "0000-01-28 00:00:00"),(84, "0000-01-28 00:00:01"),(85, "0000-01-28 00:00:01"),(86, "0000-01-28 00:00:01"),(87, "0000-01-28 00:00:59"),(88, "0000-01-28 00:00:59"),(89, "0000-01-28 00:00:59"),(90, "0000-01-28 00:01:00"),(91, "0000-01-28 00:01:00"),(92, "0000-01-28 00:01:00"),(93, "0000-01-28 00:01:01"),(94, "0000-01-28 00:01:01"),(95, "0000-01-28 00:01:01"),(96, "0000-01-28 00:01:59"),(97, "0000-01-28 00:01:59"),(98, "0000-01-28 00:01:59"),(99, "0000-01-28 00:59:00"),
      (100, "0000-01-28 00:59:00"),(101, "0000-01-28 00:59:00"),(102, "0000-01-28 00:59:01"),(103, "0000-01-28 00:59:01"),(104, "0000-01-28 00:59:01"),(105, "0000-01-28 00:59:59"),(106, "0000-01-28 00:59:59"),(107, "0000-01-28 00:59:59"),(108, "0000-01-28 01:00:00"),(109, "0000-01-28 01:00:00"),(110, "0000-01-28 01:00:00"),(111, "0000-01-28 01:00:01"),(112, "0000-01-28 01:00:01"),(113, "0000-01-28 01:00:01"),(114, "0000-01-28 01:00:59"),(115, "0000-01-28 01:00:59"),(116, "0000-01-28 01:00:59"),(117, "0000-01-28 01:01:00"),(118, "0000-01-28 01:01:00"),(119, "0000-01-28 01:01:00"),
      (120, "0000-01-28 01:01:01"),(121, "0000-01-28 01:01:01"),(122, "0000-01-28 01:01:01"),(123, "0000-01-28 01:01:59"),(124, "0000-01-28 01:01:59"),(125, "0000-01-28 01:01:59"),(126, "0000-01-28 01:59:00"),(127, "0000-01-28 01:59:00"),(128, "0000-01-28 01:59:00"),(129, "0000-01-28 01:59:01"),(130, "0000-01-28 01:59:01"),(131, "0000-01-28 01:59:01"),(132, "0000-01-28 01:59:59"),(133, "0000-01-28 01:59:59"),(134, "0000-01-28 01:59:59"),(135, "0000-01-28 23:00:00"),(136, "0000-01-28 23:00:00"),(137, "0000-01-28 23:00:00"),(138, "0000-01-28 23:00:01"),(139, "0000-01-28 23:00:01"),
      (140, "0000-01-28 23:00:01"),(141, "0000-01-28 23:00:59"),(142, "0000-01-28 23:00:59"),(143, "0000-01-28 23:00:59"),(144, "0000-01-28 23:01:00"),(145, "0000-01-28 23:01:00"),(146, "0000-01-28 23:01:00"),(147, "0000-01-28 23:01:01"),(148, "0000-01-28 23:01:01"),(149, "0000-01-28 23:01:01"),(150, "0000-01-28 23:01:59"),(151, "0000-01-28 23:01:59"),(152, "0000-01-28 23:01:59"),(153, "0000-01-28 23:59:00"),(154, "0000-01-28 23:59:00"),(155, "0000-01-28 23:59:00"),(156, "0000-01-28 23:59:01"),(157, "0000-01-28 23:59:01"),(158, "0000-01-28 23:59:01"),(159, "0000-01-28 23:59:59"),
      (160, "0000-01-28 23:59:59"),(161, "0000-01-28 23:59:59"),(162, "0000-12-01 00:00:00"),(163, "0000-12-01 00:00:00"),(164, "0000-12-01 00:00:00"),(165, "0000-12-01 00:00:01"),(166, "0000-12-01 00:00:01"),(167, "0000-12-01 00:00:01"),(168, "0000-12-01 00:00:59"),(169, "0000-12-01 00:00:59"),(170, "0000-12-01 00:00:59"),(171, "0000-12-01 00:01:00"),(172, "0000-12-01 00:01:00"),(173, "0000-12-01 00:01:00"),(174, "0000-12-01 00:01:01"),(175, "0000-12-01 00:01:01"),(176, "0000-12-01 00:01:01"),(177, "0000-12-01 00:01:59"),(178, "0000-12-01 00:01:59"),(179, "0000-12-01 00:01:59"),
      (180, "0000-12-01 00:59:00"),(181, "0000-12-01 00:59:00"),(182, "0000-12-01 00:59:00"),(183, "0000-12-01 00:59:01"),(184, "0000-12-01 00:59:01"),(185, "0000-12-01 00:59:01"),(186, "0000-12-01 00:59:59"),(187, "0000-12-01 00:59:59"),(188, "0000-12-01 00:59:59"),(189, "0000-12-01 01:00:00"),(190, "0000-12-01 01:00:00"),(191, "0000-12-01 01:00:00"),(192, "0000-12-01 01:00:01"),(193, "0000-12-01 01:00:01"),(194, "0000-12-01 01:00:01")
      ,(195, null);
    """

    sql "set enable_strict_cast=true;"
    qt_sql_0_strict 'select f1, cast(f2 as largeint) from test_cast_to_largeint_from_datetimev2_0_part0_0_nullable order by 1;'

    sql "set enable_strict_cast=false;"
    qt_sql_0_non_strict 'select f1, cast(f2 as largeint) from test_cast_to_largeint_from_datetimev2_0_part0_0_nullable order by 1;'

    sql "drop table if exists test_cast_to_largeint_from_datetimev2_0_part0_0_not_nullable;"
    sql "create table test_cast_to_largeint_from_datetimev2_0_part0_0_not_nullable(f1 int, f2 datetimev2(0)) properties('replication_num'='1');"
    sql """insert into test_cast_to_largeint_from_datetimev2_0_part0_0_not_nullable values (0, "0000-01-01 00:00:00"),(1, "0000-01-01 00:00:00"),(2, "0000-01-01 00:00:00"),(3, "0000-01-01 00:00:01"),(4, "0000-01-01 00:00:01"),(5, "0000-01-01 00:00:01"),(6, "0000-01-01 00:00:59"),(7, "0000-01-01 00:00:59"),(8, "0000-01-01 00:00:59"),(9, "0000-01-01 00:01:00"),(10, "0000-01-01 00:01:00"),(11, "0000-01-01 00:01:00"),(12, "0000-01-01 00:01:01"),(13, "0000-01-01 00:01:01"),(14, "0000-01-01 00:01:01"),(15, "0000-01-01 00:01:59"),(16, "0000-01-01 00:01:59"),(17, "0000-01-01 00:01:59"),(18, "0000-01-01 00:59:00"),(19, "0000-01-01 00:59:00"),
      (20, "0000-01-01 00:59:00"),(21, "0000-01-01 00:59:01"),(22, "0000-01-01 00:59:01"),(23, "0000-01-01 00:59:01"),(24, "0000-01-01 00:59:59"),(25, "0000-01-01 00:59:59"),(26, "0000-01-01 00:59:59"),(27, "0000-01-01 01:00:00"),(28, "0000-01-01 01:00:00"),(29, "0000-01-01 01:00:00"),(30, "0000-01-01 01:00:01"),(31, "0000-01-01 01:00:01"),(32, "0000-01-01 01:00:01"),(33, "0000-01-01 01:00:59"),(34, "0000-01-01 01:00:59"),(35, "0000-01-01 01:00:59"),(36, "0000-01-01 01:01:00"),(37, "0000-01-01 01:01:00"),(38, "0000-01-01 01:01:00"),(39, "0000-01-01 01:01:01"),
      (40, "0000-01-01 01:01:01"),(41, "0000-01-01 01:01:01"),(42, "0000-01-01 01:01:59"),(43, "0000-01-01 01:01:59"),(44, "0000-01-01 01:01:59"),(45, "0000-01-01 01:59:00"),(46, "0000-01-01 01:59:00"),(47, "0000-01-01 01:59:00"),(48, "0000-01-01 01:59:01"),(49, "0000-01-01 01:59:01"),(50, "0000-01-01 01:59:01"),(51, "0000-01-01 01:59:59"),(52, "0000-01-01 01:59:59"),(53, "0000-01-01 01:59:59"),(54, "0000-01-01 23:00:00"),(55, "0000-01-01 23:00:00"),(56, "0000-01-01 23:00:00"),(57, "0000-01-01 23:00:01"),(58, "0000-01-01 23:00:01"),(59, "0000-01-01 23:00:01"),
      (60, "0000-01-01 23:00:59"),(61, "0000-01-01 23:00:59"),(62, "0000-01-01 23:00:59"),(63, "0000-01-01 23:01:00"),(64, "0000-01-01 23:01:00"),(65, "0000-01-01 23:01:00"),(66, "0000-01-01 23:01:01"),(67, "0000-01-01 23:01:01"),(68, "0000-01-01 23:01:01"),(69, "0000-01-01 23:01:59"),(70, "0000-01-01 23:01:59"),(71, "0000-01-01 23:01:59"),(72, "0000-01-01 23:59:00"),(73, "0000-01-01 23:59:00"),(74, "0000-01-01 23:59:00"),(75, "0000-01-01 23:59:01"),(76, "0000-01-01 23:59:01"),(77, "0000-01-01 23:59:01"),(78, "0000-01-01 23:59:59"),(79, "0000-01-01 23:59:59"),
      (80, "0000-01-01 23:59:59"),(81, "0000-01-28 00:00:00"),(82, "0000-01-28 00:00:00"),(83, "0000-01-28 00:00:00"),(84, "0000-01-28 00:00:01"),(85, "0000-01-28 00:00:01"),(86, "0000-01-28 00:00:01"),(87, "0000-01-28 00:00:59"),(88, "0000-01-28 00:00:59"),(89, "0000-01-28 00:00:59"),(90, "0000-01-28 00:01:00"),(91, "0000-01-28 00:01:00"),(92, "0000-01-28 00:01:00"),(93, "0000-01-28 00:01:01"),(94, "0000-01-28 00:01:01"),(95, "0000-01-28 00:01:01"),(96, "0000-01-28 00:01:59"),(97, "0000-01-28 00:01:59"),(98, "0000-01-28 00:01:59"),(99, "0000-01-28 00:59:00"),
      (100, "0000-01-28 00:59:00"),(101, "0000-01-28 00:59:00"),(102, "0000-01-28 00:59:01"),(103, "0000-01-28 00:59:01"),(104, "0000-01-28 00:59:01"),(105, "0000-01-28 00:59:59"),(106, "0000-01-28 00:59:59"),(107, "0000-01-28 00:59:59"),(108, "0000-01-28 01:00:00"),(109, "0000-01-28 01:00:00"),(110, "0000-01-28 01:00:00"),(111, "0000-01-28 01:00:01"),(112, "0000-01-28 01:00:01"),(113, "0000-01-28 01:00:01"),(114, "0000-01-28 01:00:59"),(115, "0000-01-28 01:00:59"),(116, "0000-01-28 01:00:59"),(117, "0000-01-28 01:01:00"),(118, "0000-01-28 01:01:00"),(119, "0000-01-28 01:01:00"),
      (120, "0000-01-28 01:01:01"),(121, "0000-01-28 01:01:01"),(122, "0000-01-28 01:01:01"),(123, "0000-01-28 01:01:59"),(124, "0000-01-28 01:01:59"),(125, "0000-01-28 01:01:59"),(126, "0000-01-28 01:59:00"),(127, "0000-01-28 01:59:00"),(128, "0000-01-28 01:59:00"),(129, "0000-01-28 01:59:01"),(130, "0000-01-28 01:59:01"),(131, "0000-01-28 01:59:01"),(132, "0000-01-28 01:59:59"),(133, "0000-01-28 01:59:59"),(134, "0000-01-28 01:59:59"),(135, "0000-01-28 23:00:00"),(136, "0000-01-28 23:00:00"),(137, "0000-01-28 23:00:00"),(138, "0000-01-28 23:00:01"),(139, "0000-01-28 23:00:01"),
      (140, "0000-01-28 23:00:01"),(141, "0000-01-28 23:00:59"),(142, "0000-01-28 23:00:59"),(143, "0000-01-28 23:00:59"),(144, "0000-01-28 23:01:00"),(145, "0000-01-28 23:01:00"),(146, "0000-01-28 23:01:00"),(147, "0000-01-28 23:01:01"),(148, "0000-01-28 23:01:01"),(149, "0000-01-28 23:01:01"),(150, "0000-01-28 23:01:59"),(151, "0000-01-28 23:01:59"),(152, "0000-01-28 23:01:59"),(153, "0000-01-28 23:59:00"),(154, "0000-01-28 23:59:00"),(155, "0000-01-28 23:59:00"),(156, "0000-01-28 23:59:01"),(157, "0000-01-28 23:59:01"),(158, "0000-01-28 23:59:01"),(159, "0000-01-28 23:59:59"),
      (160, "0000-01-28 23:59:59"),(161, "0000-01-28 23:59:59"),(162, "0000-12-01 00:00:00"),(163, "0000-12-01 00:00:00"),(164, "0000-12-01 00:00:00"),(165, "0000-12-01 00:00:01"),(166, "0000-12-01 00:00:01"),(167, "0000-12-01 00:00:01"),(168, "0000-12-01 00:00:59"),(169, "0000-12-01 00:00:59"),(170, "0000-12-01 00:00:59"),(171, "0000-12-01 00:01:00"),(172, "0000-12-01 00:01:00"),(173, "0000-12-01 00:01:00"),(174, "0000-12-01 00:01:01"),(175, "0000-12-01 00:01:01"),(176, "0000-12-01 00:01:01"),(177, "0000-12-01 00:01:59"),(178, "0000-12-01 00:01:59"),(179, "0000-12-01 00:01:59"),
      (180, "0000-12-01 00:59:00"),(181, "0000-12-01 00:59:00"),(182, "0000-12-01 00:59:00"),(183, "0000-12-01 00:59:01"),(184, "0000-12-01 00:59:01"),(185, "0000-12-01 00:59:01"),(186, "0000-12-01 00:59:59"),(187, "0000-12-01 00:59:59"),(188, "0000-12-01 00:59:59"),(189, "0000-12-01 01:00:00"),(190, "0000-12-01 01:00:00"),(191, "0000-12-01 01:00:00"),(192, "0000-12-01 01:00:01"),(193, "0000-12-01 01:00:01"),(194, "0000-12-01 01:00:01");
    """

    sql "set enable_strict_cast=true;"
    qt_sql_0_strict 'select f1, cast(f2 as largeint) from test_cast_to_largeint_from_datetimev2_0_part0_0_not_nullable order by 1;'

    sql "set enable_strict_cast=false;"
    qt_sql_0_non_strict 'select f1, cast(f2 as largeint) from test_cast_to_largeint_from_datetimev2_0_part0_0_not_nullable order by 1;'

}